USE [ShortenUrl]
GO

/****** Object:  Table [dbo].[ShortenUsers]    Script Date: 11/14/2012 16:41:02 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ShortenUsers]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ShortenUsers](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](50) NOT NULL,
	[Email] [varchar](100) NOT NULL,
	[Username] [varchar](50) NOT NULL,
	[Password] [varchar](32) NOT NULL,
	[ProfileImage] [image] NULL,
	[GroupId] [int] NULL,
	[InsertDate] [datetime] NOT NULL,
 CONSTRAINT [PK_ShortenUser] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO

SET ANSI_PADDING OFF
GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShortenUsers_ShortenGroups]') AND parent_object_id = OBJECT_ID(N'[dbo].[ShortenUsers]'))
ALTER TABLE [dbo].[ShortenUsers]  WITH CHECK ADD  CONSTRAINT [FK_ShortenUsers_ShortenGroups] FOREIGN KEY([GroupId])
REFERENCES [dbo].[ShortenGroups] ([Id])
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShortenUsers_ShortenGroups]') AND parent_object_id = OBJECT_ID(N'[dbo].[ShortenUsers]'))
ALTER TABLE [dbo].[ShortenUsers] CHECK CONSTRAINT [FK_ShortenUsers_ShortenGroups]
GO

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ShortenUsers_InsertDate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ShortenUsers] ADD  CONSTRAINT [DF_ShortenUsers_InsertDate]  DEFAULT (getdate()) FOR [InsertDate]
END

GO


